export const getType = (type: string = 'year', time: string | number = '') => {
  const date = time ? new Date(time) : new Date();
  let value: number;
  switch (type) {
    case 'year':
      value = date.getFullYear(); // 获取当前年份
      break;
    case 'month':
      value = date.getMonth() + 1; // 获取当前月份
      break;
    case 'date':
      value = date.getDate(); // 获取当前日
      break;
    case 'day':
      value = date.getDay(); // 获取当前星期几
      break;
    case 'hours':
      value = date.getHours(); // 获取小时
      break;
    case 'minutes':
      value = date.getMinutes(); // 获取分钟
      break;
    case 'seconds':
      value = date.getSeconds(); // 获取秒
      break;
    default:
      value = date.getFullYear(); // 获取当前年份
      break;
  }
  return value;
};
export const getDateParse = (time: string | number = '') => {
  return {
    year: getType('year', time),
    month: getType('month', time),
    date: getType('date', time),
    day: getType('day', time),
    hours: getType('hours', time),
    minutes: getType('minutes', time),
    seconds: getType('seconds', time)
  };
};

export const getNumber = (t: number | string) => {
  return t <= 9 ? `0${t}` : t;
};
